﻿using System;
using System.ServiceModel;
using System.ServiceProcess;

namespace Service
{
    public class DMSWindowsService : ServiceBase
    {
        private ServiceHost serviceHost = null;

        public DMSWindowsService()
        {
            base.ServiceName = "DMS Tools WCF Service";
        }

        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }
            serviceHost = new ServiceHost(typeof(DMSServices));
            serviceHost.Open();
        }

        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }

        static void Main(string[] args)
        {
            ServiceBase.Run(new DMSWindowsService());
        }
    }
}
